﻿using System;
using System.Windows.Controls;
using TheOliver.DigitalSignage.Client.Interfaces;

namespace AllEvents.Base
{
    public partial class SilverlightPromo : UserControl, ISlide, IInteractiveSlide
    {
        public SilverlightPromo()
        {
            InitializeComponent();

            _video.MediaEnded += (s, e) =>
                {
                    if (Finished != null)
                    {
                        Finished(this, EventArgs.Empty);
                    }
                };
        }

        public event EventHandler Finished;

        public int DisplayDuration
        {
            get { return 0; }
        }

        public void Start()
        {
            if (_video.CurrentState == System.Windows.Media.MediaElementState.Opening)
            {
                _video.MediaOpened += (s, e) =>
                    {
                        _video.Stop();
                        _video.Play();
                    };
            }
            else
            {
                _video.Stop();
                _video.Play();
            }
        }

        public bool HasContent
        {
            get { return true; }
        }
    }
}
